package com.usian;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext-redis.xml")
public class List {
    @Autowired
    private RedisTemplate redisTemplate;
    //右插入
    @Test
    public void set(){
        redisTemplate.boundListOps("zhu").rightPush("5445");
        redisTemplate.boundListOps("zhu").rightPush("545545");
        redisTemplate.boundListOps("zhu").rightPush("5455");
        redisTemplate.boundListOps("zhu").rightPush("54255");
    }
    //显示右的集合
    @Test
    public void get(){
        Object zhu = redisTemplate.boundListOps("zhu").range(0,1);
        System.out.println(zhu);
    }
    //左插入
    @Test
    public void set2(){
        redisTemplate.boundListOps("zhu").leftPush("654565");
        redisTemplate.boundListOps("zhu").leftPush("654565445");
        redisTemplate.boundListOps("zhu").leftPush("6545512");
        redisTemplate.boundListOps("zhu").leftPush("654554");
    }
    //显示左集合
    @Test
    public void get2(){
        Object zhu = redisTemplate.boundListOps("zhu").range(0,3);
        System.out.println(zhu);
    }
    //单查
    @Test
    public void show(){
        Object zhh = redisTemplate.boundListOps("zhu").index(2);
        System.out.println(zhh);
    }
    //指定删除
    @Test
    public void delete(){
        redisTemplate.boundListOps("zhu").remove(1,"6545512");
    }
}
